package com.ironman.common.entity;

import lombok.Getter;

import java.util.Date;
import java.util.Objects;

@Getter
public class YawData extends BaseData {

    /**
     * 船首向偏航角Z轴
     */
    private final Double yaw;

    public YawData(Date ts, Double yaw) {
        super(ts);
        this.yaw = yaw;
    }

    @Override
    public Double calValue() {
        if (Objects.isNull(yaw)) {
            return null;
        }
        // 转换为指北坐标
        if (-180 <= yaw && yaw < 90) {
            return 90 - yaw;
        }
        return 450 - yaw;
    }
}